package com.person.android.resource;

import android.content.Context;
import android.content.SharedPreferences;

import com.person.android.dao.UIRenderParameter;

/**
 * @autor zhaokang.
 * @time on 2015/12/14.
 */
public class XMLReader {

    public static UIRenderParameter getUIParameter(Context context){
        UIRenderParameter renderParameter = new UIRenderParameter();
        SharedPreferences sp = context.getSharedPreferences(FilePathUtils.mRendertUIFilePath, Context.MODE_PRIVATE);
        renderParameter.mProEyeValue = sp.getBoolean(UIRenderParameter.mProtectedEyeKey, true);
        renderParameter.mNavColorValue = sp.getInt(UIRenderParameter.mNavColorSetKey, 0);
        renderParameter.mUIColorValue = sp.getInt(UIRenderParameter.mUISetKey,0);
        return renderParameter;
    }

    public static int saveUIRenderParameter(Context context,UIRenderParameter parameter){
        SharedPreferences.Editor editor = context.getSharedPreferences(FilePathUtils.mRendertUIFilePath,Context.MODE_PRIVATE).edit();
        editor.putBoolean(UIRenderParameter.mProtectedEyeKey,parameter.mProEyeValue);
        editor.putInt(UIRenderParameter.mNavColorSetKey, parameter.mNavColorValue);
        editor.putInt(UIRenderParameter.mUISetKey, parameter.mUIColorValue);
        editor.apply();
        return 1;
    }

}
